async function main(){
    return 'def'
    throw 'abc'
}
main().then(res=>{
    console.log(res)   //def
},err=>{
    console.log(err,'err')  //abc
})


function test1(){
    console.log('test1')
    return 'bbb'
}
async function test(){
    const data = await test1()  //如果后面跟的不是promise，会被await隐式转换成promise.resolve('bbb')
    console.log(data,'data')
    console.log('1')
    return '1223'
}
test()
console.log('2')
console.log('3')

//输出结果：test1 2 3 bbb 1


async function test1(){
    const data = await 1        //如果后面跟的不是promise，会被await隐式转换成promise.resolve(1)
    console.log(data,'data')   //但由于promise.resolve(1)是微任务，故先执行其他同步代码，先输出2 3
    console.log('1')          //等同步代码执行完毕，输出1
    return '1223'
}
test1()
console.log('2')
console.log('3')